package com.wen.springbootdistributionserver.service;

import com.wen.springbootdistributionserver.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(rollbackFor = Exception.class)
public class DispatchService {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void dispatch(String orderId)throws Exception{
        String sql = "insert into dispatch(order_id,name,content,create_time,dister)values(?,?,?,?,?)";
        int i = jdbcTemplate.update(sql, orderId, "wen", "泡面", DateUtil.getDate(DateUtil.DateFormat1), "小王");

        if(i != 1){
            throw new Exception("订单创建失败，入运单库出错");
        }

    }

}
